from network import *

class GameServer(Thread):
   
    def __init__(self,game,address):
        Thread.__init__(self)
        self.game = game
        self.server_socket = socket()
        self.server_socket.bind(address)
        self.server_socket.listen(1)
       
    def run(self):
        client_socket, client_address = self.server_socket.accept()
        message_processor = MessageProcessor(self.game)
        while game.status != CombatGame.END:
            information = client_socket.recv(1024)
            message = compilate_information(information)
            message_processor.process_message(message)
            while is_my_turn(): #################
                my_information = "Information before the end's turn"
            client_socket.send(my_information)


g = CombatGame()
g_server = GameServer(g,('lcc24',8003))
g_server.start()
mp = MessageProcessor(g)
mp.game.add_piece('marshal',0,0)
mp.game.change_status(mp.game.BATTLE)
mp.game.move(0,0,0,1)
print mp.game.table.get(0,0)
print mp.game.table.get(0,1)
